home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / ODFDev / ODF / Found / FWMemory / FWMemMgr.h < prev    next >
Encoding:
Text File  |  1996-09-17  |  5.3 KB  |  133 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWMemMgr.h
  4. //    Release Version:    $ ODF 2 $
  5. //
  6. //    Copyright:    (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #ifndef FWMEMMGR_H
  11. #define FWMEMMGR_H
  12.  
  13. #ifndef SLMEMMGR_H
  14. #include "SLMemMgr.h"
  15. #endif
  16.  
  17. //========================================================================================
  18. // CLASS FW_CMemoryManager
  19. //========================================================================================
  20.  
  21. class FW_CMemoryManager
  22. {
  23. public:
  24.  
  25.     // Utility routines for manipulating blocks of memory
  26.     static void CopyMemory(const void* const source,
  27.                            void* const destination,
  28.                            unsigned long bytesToMove);
  29.     static void SetMemory(void* aBlock,
  30.                           unsigned long bytesToSet,
  31.                           unsigned char byteValue);
  32.     static void* AddOffsetToPointer(void* pointer,
  33.                                     unsigned long offset);
  34.  
  35.     // when resizable, pointer-based blocks are needed:
  36.     static void* AllocateBlock(unsigned long bytesRequested);
  37.     static void* ResizeBlock(void* aBlock, unsigned long bytesRequested);
  38.     static unsigned long GetBlockSize(const void* aBlock);
  39.     static void FreeBlock(void* aBlock);
  40.  
  41.     // when platform specific handles are needed:
  42.     static FW_PlatformHandle AllocateSystemHandle(unsigned long bytesRequested);
  43.     static FW_PlatformHandle ResizeSystemHandle(FW_PlatformHandle aHandle,
  44.                                                 unsigned long bytesRequested);
  45.     static void FreeSystemHandle(FW_PlatformHandle aHandle);
  46.     static void* LockSystemHandle(FW_PlatformHandle aHandle);
  47.     static void UnlockSystemHandle(FW_PlatformHandle aHandle);
  48.     static unsigned long GetSystemHandleSize(FW_PlatformHandle aHandle);
  49.     static FW_PlatformHandle CopySystemHandle(FW_PlatformHandle aHandle);
  50.  
  51.     //internal methods
  52.     // when resizable, pointer-based blocks are needed, no debug checking:
  53.     static void DefaultNewHandler();
  54.  
  55. private:
  56.     FW_CMemoryManager() {};
  57.         // abstract class.  Note that all methods are statics.
  58. };
  59.  
  60. //========================================================================================
  61. // FW_CMemoryManager inlines
  62. //========================================================================================
  63.  
  64. //----------------------------------------------------------------------------------------
  65. // FW_CMemoryManager::CopyMemory - 
  66. //----------------------------------------------------------------------------------------
  67. inline void FW_CMemoryManager::CopyMemory(const void* const source,
  68.                                           void* const destination,
  69.                                           unsigned long bytesToMove)
  70. {
  71.     FW_PrivMemoryManager_CopyMemory(source, destination, bytesToMove);
  72. }
  73.  
  74. //----------------------------------------------------------------------------------------
  75. // FW_CMemoryManager::SetMemory - 
  76. //----------------------------------------------------------------------------------------
  77. inline void FW_CMemoryManager::SetMemory(void* aBlock,
  78.                                          unsigned long bytesToSet,
  79.                                          unsigned char byteValue)
  80. {
  81.     FW_PrivMemoryManager_SetMemory(aBlock, bytesToSet, byteValue);
  82. }
  83.  
  84. //----------------------------------------------------------------------------------------
  85. // FW_CMemoryManager::AddOffsetToPointer
  86. //----------------------------------------------------------------------------------------
  87. inline void* FW_CMemoryManager::AddOffsetToPointer(void* pointer, unsigned long offset)
  88. {
  89.     return FW_PrivMemoryManager_AddOffsetToPointer(pointer, offset);
  90. }
  91.  
  92. //----------------------------------------------------------------------------------------
  93. // FW_CMemoryManager::GetBlockSize - Return a non-relocatable block to the free store.
  94. //----------------------------------------------------------------------------------------
  95. inline unsigned long FW_CMemoryManager::GetBlockSize(const void* aBlock)
  96. {
  97.     return FW_PrivMemoryManager_GetBlockSize(aBlock);
  98. }
  99.  
  100. //----------------------------------------------------------------------------------------
  101. // FW_CMemoryManager::FreeBlock - Return a non-relocatable block to the free store.
  102. //----------------------------------------------------------------------------------------
  103. inline void FW_CMemoryManager::FreeBlock(void* aBlock)
  104. {
  105.     FW_PrivMemoryManager_FreeBlock(aBlock);
  106. }
  107.  
  108. //----------------------------------------------------------------------------------------
  109. // FW_CMemoryManager::FreeSystemHandle - 
  110. //----------------------------------------------------------------------------------------
  111. inline void FW_CMemoryManager::FreeSystemHandle(FW_PlatformHandle aHandle)
  112. {
  113.     FW_PrivMemoryManager_FreeSystemHandle(aHandle);
  114. }
  115.  
  116. //----------------------------------------------------------------------------------------
  117. // FW_CMemoryManager::UnlockSystemHandle - 
  118. //----------------------------------------------------------------------------------------
  119. inline void FW_CMemoryManager::UnlockSystemHandle(FW_PlatformHandle aHandle)
  120. {
  121.     FW_PrivMemoryManager_UnlockSystemHandle(aHandle);
  122. }
  123.  
  124. //----------------------------------------------------------------------------------------
  125. // FW_CMemoryManager::GetSystemHandleSize
  126. //----------------------------------------------------------------------------------------
  127. inline unsigned long FW_CMemoryManager::GetSystemHandleSize(FW_PlatformHandle aHandle)
  128. {
  129.     return FW_PrivMemoryManager_GetSystemHandleSize(aHandle);
  130. }
  131.  
  132. #endif
  133.